package com.zbkj.admin.controller.mszs;

import com.zbkj.common.model.mszs.MszsRoom;
import com.zbkj.common.page.CommonPage;
import com.zbkj.common.request.mszs.MszsRoomRequest;
import com.zbkj.common.request.mszs.MszsRoomSelectRequest;
import com.zbkj.common.response.CommonResult;
import com.zbkj.common.response.mszs.MszsRoomResponse;
import com.zbkj.service.service.mszs.MszsRoomService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@RestController("MszsRoomAdminController")
@RequestMapping("api/admin/mszs/room")
@Api(tags = "民宿助手-管理平台-酒店房间信息")
public class MszsRoomController {

    @Resource
    private MszsRoomService roomService;

    @PreAuthorize("hasAuthority('admin:mszs:room:insert')")
    @ApiOperation(value="新增-酒店房间信息")
    @RequestMapping(value = "/insert",method = RequestMethod.POST)
    public CommonResult<Boolean> insert(@RequestBody @Validated MszsRoomRequest request){
        return CommonResult.success(roomService.insert(request));
    }

    @PreAuthorize("hasAuthority('admin:mszs:room:update')")
    @ApiOperation(value="修改-酒店房间信息")
    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public CommonResult<Boolean> update(@RequestBody @Validated MszsRoomRequest request){
        return CommonResult.success(roomService.update(request));
    }

    @PreAuthorize("hasAuthority('admin:mszs:room:delete')")
    @ApiOperation(value="刪除-根据id标识删除")
    @RequestMapping(value = "/delete", method = RequestMethod.GET)
    @ApiImplicitParam(name = "id", value = "主键id标识",required = true)
    public CommonResult<Boolean> del(@RequestParam("id")Integer id){
        return CommonResult.success(roomService.delete(id));
    }

    @PreAuthorize("hasAuthority('admin:mszs:room:load')")
    @ApiOperation(value="查询-根据主键id")
    @RequestMapping(value = "/load", method = RequestMethod.GET)
    @ApiImplicitParam(name = "id", value = "主键id标识",required = true)
    public CommonResult<MszsRoomResponse> load(@RequestParam("id") Integer id) {
        return CommonResult.success(roomService.load(id));
    }

    @PreAuthorize("hasAuthority('admin:mszs:room:pageList')")
    @ApiOperation(value="查询-分页")
    @RequestMapping(value = "/pageList", method = RequestMethod.GET)
    public CommonResult<CommonPage<MszsRoom>> pageList(@Validated MszsRoomSelectRequest request) {
        CommonPage<MszsRoom> mszsOrderPage = CommonPage.restPage(roomService.pageList(request));
        return CommonResult.success(mszsOrderPage);
    }

    @PreAuthorize("hasAuthority('admin:mszs:room:roomPageList')")
    @ApiOperation(value="查询-所有房间")
    @RequestMapping(value = "/roomPageList", method = RequestMethod.GET)
    public CommonResult<CommonPage<MszsRoomResponse>> roomPageList(@Validated MszsRoomSelectRequest selectRequest) {

        return CommonResult.success(CommonPage.restPage(roomService.roomPageList(selectRequest)));
    }

//    @ApiOperation(value="查询-所有未入住房间")
//    @RequestMapping(value = "/notCheckInList", method = RequestMethod.GET)
//    public CommonResult<CommonPage<MszsRoomResponse>> notCheckInList(@Validated MszsRoomSelectRequest selectRequest) {
//
//        return CommonResult.success(CommonPage.restPage(roomService.notCheckInList(selectRequest)));
//    }

//    @ApiOperation(value="查询-已入住房间订单记录")
//    @RequestMapping(value = "/checkInList", method = RequestMethod.GET)
//    public CommonResult<CommonPage<MszsRoomResponse>> checkInList(@Validated MszsRoomSelectRequest selectRequest) {
//
//        return CommonResult.success(CommonPage.restPage(roomService.checkInList(selectRequest)));
//    }

}
